package org.xshop.web;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.xshop.model.TStore;
import org.xshop.service.ITStoreService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import top.ibase4j.core.base.AppBaseController;
import top.ibase4j.core.util.WebUtil;

/**
 * <p>
 * 商品热搜 前端控制器
 * </p>
 *
 * @author Liux
 * @since 2018-05-16
 */
@Controller
@RequestMapping("/app/store/")
@Api(tags = "Store", value = "商店", description = "商店")
public class TStoreController extends AppBaseController<TStore, ITStoreService> {
	@ApiOperation(value = "附近商店列表", notes = "附近商店列表", produces = MediaType.APPLICATION_JSON_VALUE, response = TStore.class)
	@RequestMapping(value = "list.api", method = { RequestMethod.GET, RequestMethod.POST })
	public Object list(HttpServletRequest request) {
		Map<String, Object> param = WebUtil.getParameter(request);
		Object result = service.getAllStore(param);
		return setSuccessModelMap(result);
	}

	@ApiOperation(value = "店铺详情", notes = "店铺详情", produces = MediaType.APPLICATION_JSON_VALUE, response = TStore.class)
	@RequestMapping(value = "detail.api", method = { RequestMethod.GET, RequestMethod.POST })
	public Object detail(HttpServletRequest request) {
		TStore param = WebUtil.getParameter(request, TStore.class);
		Assert.notNull(param.getId(), "商铺ID不能为空");
		TStore store = service.queryById(param.getId());
		return setSuccessModelMap(store);
	}

}
